home *** CD-ROM | disk | FTP | other *** search
/ Multimedia Jumpstart / Multimedia Microsoft Jumpstart Version 1.1a (Microsoft).BIN / develpmt / examples / infobrws / src / dialogs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-18  |  8.2 KB  |  199 lines

  1.  //     (C) Copyright Microsoft Corp. 1991.  All rights reserved.
  2. //
  3. //     You have a royalty-free right to use, modify, reproduce and 
  4. //     distribute the Sample Files (and/or any modified version) in 
  5. //     any way you find useful, provided that you agree that 
  6. //     Microsoft has no warranty obligations or liability for any 
  7. //     Sample Application Files which are modified. 
  8.  
  9.  
  10. /****************************************************************************
  11.  
  12.     MODULE    : DIALOGS.C
  13.  
  14.     PURPOSE   : This module contains the dialog box procedures used in the application playvfw.
  15.  
  16.     FUNCTIONS :  
  17.                 ButtonBarProc
  18.  
  19.     COMMENTS  : 
  20.  
  21.     HISTORY   : Created by Steven Molstad 8/15/93
  22.  
  23. ****************************************************************************/
  24.  
  25. #include "windows.h"
  26. #include <stdlib.h>
  27. #include "playvfw.h"
  28. #include "proto.h"
  29. #include "mmsystem.h"
  30. #include <digitalv.h>
  31. #include <stdio.h>
  32. #include <time.h>
  33.  
  34.  
  35.  
  36. /****************************************************************************
  37.  
  38.     FUNCTION  : ButtonBarProc( HANDLE, unsigned, WORD, LONG )
  39.  
  40.     PURPOSE   : The ButtonBarProc is the dialog box procedure for the Video Playback Control.  The Video 
  41.                 Playback Control is used to navigate through a Video for Windows file.  The control supports
  42.                 play, pause, rewind, step reverse, step forward, stop.  
  43.     
  44.     COMMENTS  : Due to palette problems I have designed the control so that when you play a video it hides
  45.                 the video buttons and when you stop the video it shows them again.  It would be very difficult
  46.                 to mix palettes between a instructional video and a video displayed in the buttons.
  47.  
  48.     HISTORY   : Created by Steven Molstad 8/10/93.
  49.  
  50. ****************************************************************************/ 
  51.  
  52. BOOL FAR PASCAL _export ButtonBarProc( hDlg, message, wParam, lParam )
  53. HWND hDlg;
  54. unsigned message;
  55. WORD wParam;
  56. LONG lParam;
  57. {
  58.  
  59.  
  60.  
  61. static BOOL bIsPaused;  
  62. static BOOL bPlayClicked;  
  63.  
  64.  
  65.     switch (message)
  66.          {  
  67.          case WM_INITDIALOG:  
  68.          
  69.          // intialize the puased variable to FALSE since when the control is created the video is
  70.          // stopped not paused.
  71.          
  72.               bIsPaused=FALSE; 
  73.               bPlayClicked=FALSE;             
  74.          break;
  75.          
  76.          
  77.          
  78.          case WM_COMMAND: 
  79.               { 
  80.             
  81.                switch (wParam)
  82.                          {
  83.                           case ID_PLAY:
  84.                                 
  85.                                 bPlayClicked=TRUE;
  86.                                 
  87.                           // when the play button is pressed we want to hide the edit window and show the
  88.                           // video window.
  89.                           
  90.                                 ShowWindow( hWndEdit, SW_HIDE );
  91.                                 ShowWindow(lpDevice9->hWnd, SW_SHOWNORMAL );
  92.                           
  93.                           // we also want to hide all the buttons to avoid any nasty palette problems.
  94.                           
  95.                                 ShowWindow( lpDevice1->hWnd, SW_HIDE );   
  96.                                 ShowWindow( lpDevice2->hWnd, SW_HIDE );
  97.                                 ShowWindow( lpDevice3->hWnd, SW_HIDE );
  98.                                 ShowWindow( lpDevice4->hWnd, SW_HIDE );
  99.                                 
  100.                           // If the video is paused we want to resume the video from where it left off.
  101.                           // If the video was stopped then we want to start playing from the begining.     
  102.                                 
  103.                                 if (bIsPaused)
  104.                                      {
  105.                                       
  106.                                       ResumeVFWFile(lpDevice9->wDeviceID);
  107.                                       bIsPaused=FALSE;
  108.                                       }
  109.                                  else
  110.                                       {
  111.                                      
  112.                                       PlayVFWFile(hWndMain,lpDevice9->hWnd,lpDevice9->wDeviceID);
  113.                                       }     
  114.                           break;
  115.                                                                                     
  116.                           case ID_STOP:  
  117.                                        
  118.                                 bPlayClicked=FALSE;       
  119.                                                                    
  120.                           // Stop the Video.  Hide the video window and show all the buttons to avoid any
  121.                           // nasty palette changes.                                         
  122.                                                                    
  123.                                 StopVFWFile(lpDevice9->wDeviceID); 
  124.                                 
  125.                                 ShowWindow(lpDevice9->hWnd, SW_HIDE );
  126.                                 ShowWindow(lpDevice1->hWnd, SW_SHOWNORMAL );
  127.                                 ShowWindow(lpDevice2->hWnd, SW_SHOWNORMAL );
  128.                                 ShowWindow(lpDevice3->hWnd, SW_SHOWNORMAL );
  129.                                 ShowWindow(lpDevice4->hWnd, SW_SHOWNORMAL ); 
  130.                                 ShowWindow( hWndButtonBar, SW_HIDE ); 
  131.                                 
  132.                           break;
  133.                      
  134.                           case ID_PAUSE:           
  135.                                 
  136.                                 if (bPlayClicked)
  137.                                     {
  138.                                     
  139.                           // If the video is paused and the user presses pause resume the video from where it
  140.                           // left off.  Otherwise pause the video.
  141.                           
  142.                                      if (bIsPaused)
  143.                                            {
  144.                                      
  145.                                             ResumeVFWFile(lpDevice9->wDeviceID);
  146.                                             bIsPaused=FALSE;
  147.                                            }
  148.                                      else    
  149.                                            {
  150.                                       
  151.                                             PauseVFWFile(lpDevice9->wDeviceID);
  152.                                             bIsPaused=TRUE;
  153.                                            }
  154.                                      }      
  155.                           break;
  156.                      
  157.                           case ID_REWIND:                     
  158.                                  if (bPlayClicked)
  159.                                       {
  160.                           // Rewind the video to the begining.     
  161.                                 
  162.                                       SeekVFWToStart(lpDevice9->wDeviceID);
  163.                                       }
  164.                           break;
  165.                      
  166.                           case ID_FORWARD: 
  167.                                  if (bPlayClicked)
  168.                                       {
  169.                           // Step the Video forward by 5 frames.  You can change this value if 5 frames is to
  170.                           // little.
  171.                                  
  172.                                        StepVFW(lpDevice9->wDeviceID,5);
  173.                                       }
  174.                           break;  
  175.                           
  176.                           case ID_BACK:   
  177.                           
  178.                                  if (bPlayClicked)
  179.                                        { 
  180.                                        
  181.                           // Step the video backwards by 1 frame.  Video for Windows does not give you any
  182.                           // additional control to step backwards more than one frame.  To achieve this you
  183.                           // would need to keep track of the position or get the current position and then 
  184.                           // seek back so many frames. I leave this as an exercise for the reader.
  185.                                 
  186.                                          StepVFWReverse(lpDevice9->wDeviceID);
  187.                                  
  188.                           break;        }
  189.                           }
  190.                      
  191.                }
  192.           break;           
  193.           
  194.           default:
  195.               return FALSE;
  196.           }   
  197.           
  198. return FALSE;